package com.xy.improve;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/18 16:08
 * @description
 */
public class BilibiliUploader implements Uploader {
    private List<User> fans = new ArrayList<>();
    private String name;
    private Object video;

    public BilibiliUploader(String name) {
        this.name = name;
    }

    @Override
    public void followFan(User fan) {
        System.out.println(fan.getName() + "关注了您...");
        fans.add(fan);
    }

    @Override
    public void unfollowFan(User fan) {
        fans.add(fan);
    }

    /**
     * 更新作品
     */
    public void upload(Object video) {
        this.video = video;
        notifyToFans();
    }

    @Override
    public void notifyToFans() {
        fans.forEach(User::update);
    }

    public String getName() {
        return name;
    }

    public Object getVideo() {
        return video;
    }
}
